Class Header

Summary

Fully Qualified Name: CodeIgniter\HTTP\Header

Description

Class Header

Represents a single HTTP header.

Methods

Name Description Defined By
__construct() Header constructor. name is mandatory, if a value is provided, it will be set. Header
__toString() Returns a representation of the entire header string, including the header name and all values converted to the proper format. Header
appendValue() Appends a value to the list of values for this header. If the header is a single value string, it will be converted to an array. Header
getName() Returns the name of the header, in the same case it was set. Header
getValue() Gets the raw value of the header. This may return either a string of an array, depending on whether the header has multiple values or not. Header
getValueLine() Retrieves a comma-separated string of the values for a single header. Header
prependValue() Prepends a value to the list of values for this header. If the header is a single value string, it will be converted to an array. Header
setName() Sets the name of the header, overwriting any previous value. Header
setValue() Sets the value of the header, overwriting any previous value(s). Header

Method Details

__construct()

Header constructor. name is mandatory, if a value is provided, it will be set.

Parameter Name Type Description
$name string
$value string|array|null

Returns:

__toString()

Returns a representation of the entire header string, including the header name and all values converted to the proper format.

Returns: string

appendValue()

Appends a value to the list of values for this header. If the header is a single value string, it will be converted to an array.

Parameter Name Type Description
$value null

Returns: $this

getName()

Returns the name of the header, in the same case it was set.

Returns: string

getValue()

Gets the raw value of the header. This may return either a string of an array, depending on whether the header has multiple values or not.

Returns: array|null|string

getValueLine()

Retrieves a comma-separated string of the values for a single header.

NOTE: Not all header values may be appropriately represented using comma concatenation. For such headers, use getHeader() instead and supply your own delimiter when concatenating.

Returns:

prependValue()

Prepends a value to the list of values for this header. If the header is a single value string, it will be converted to an array.

Parameter Name Type Description
$value null

Returns: $this

setName()

Sets the name of the header, overwriting any previous value.

Parameter Name Type Description
$name string

Returns: $this

setValue()

Sets the value of the header, overwriting any previous value(s).

Parameter Name Type Description
$value null

Returns: $this

Top